#include "mainwindow.h"
#include <QApplication>
#include "database.h"
#include <QFile>

static void loadStyle(const QString styleName){
    //加载样式表
    QString qss;
    QFile file(styleName);
    if (file.open(QFile::ReadOnly)) {
        //用QTextStream读取样式文件不用区分文件编码 带bom也行
        QStringList list;
        QTextStream in(&file);
        while (!in.atEnd()) {
            QString line;
            in >> line;
            list << line;
        }

        file.close();
        qss = list.join("\n");
        QString paletteColor = qss.mid(20, 7);
        qApp->setPalette(QPalette(paletteColor));
        //用时主要在下面这句
        qApp->setStyleSheet(qss);
    }

}
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    if(!connectdatabase("ticketbookingsys"))
    {
        QMessageBox::about(NULL, "提示", "无法连接到数据库");
        return 1;
    }
    loadStyle(":/qss/lightblue.css");

    MainWindow w;
    w.show();
    return a.exec();
}
